import type { CustomerForm, CustomerQuery, CustomerVO } from './model';

import type { ID, IDS, PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 查询客户管理列表
 * @param params
 * @returns 客户管理列表
 */
export function customerList(params?: CustomerQuery) {
  return requestClient.get<PageResult<CustomerVO>>('/trade/customer/list', {
    params,
  });
}

/**
 * 导出客户管理列表
 * @param params
 * @returns 客户管理列表
 */
export function customerExport(params?: CustomerQuery) {
  return commonExport('/trade/customer/export', params ?? {});
}

/**
 * 查询客户管理详情
 * @param id id
 * @returns 客户管理详情
 */
export function customerInfo(id: ID) {
  return requestClient.get<CustomerVO>(`/trade/customer/${id}`);
}

/**
 * 新增客户管理
 * @param data
 * @returns void
 */
export function customerAdd(data: CustomerForm) {
  return requestClient.postWithMsg<void>('/trade/customer', data);
}

/**
 * 更新客户管理
 * @param data
 * @returns void
 */
export function customerUpdate(data: CustomerForm) {
  return requestClient.putWithMsg<void>('/trade/customer', data);
}

/**
 * 删除客户管理
 * @param id id
 * @returns void
 */
export function customerRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/trade/customer/${id}`);
}
